package com.compass.doctor.ui.chat.viewholder;

import android.view.LayoutInflater;
import android.view.View;

import androidx.annotation.NonNull;

import com.compass.doctor.R;
import com.compass.doctor.databinding.ChatMessageExamineViewHolderBinding;
import com.compass.doctor.databinding.ChatMessageHospitalizationViewHolderBinding;
import com.compass.doctor.databinding.ChatMessagePrescriptionViewHolderBinding;
import com.compass.doctor.ui.chat.attachment.HospitalizationCertificateAttachment;
import com.compass.doctor.ui.chat.attachment.InquiryAttachment;
import com.netease.yunxin.kit.chatkit.ui.common.MessageHelper;
import com.netease.yunxin.kit.chatkit.ui.databinding.ChatBaseMessageViewHolderBinding;
import com.netease.yunxin.kit.chatkit.ui.fun.view.message.viewholder.FunChatBaseMessageViewHolder;
import com.netease.yunxin.kit.chatkit.ui.model.ChatMessageBean;

/**
 * Description：住院证ViewHolder
 * Date:2024/1/22 17:17
 */
public class HospitalizationCertificateViewHolder extends FunChatBaseMessageViewHolder {
    public static final String TAG = "InquiryViewHolder";
    ChatMessageHospitalizationViewHolderBinding binding;
    HospitalizationCertificateAttachment attachment;

    public HospitalizationCertificateViewHolder(@NonNull ChatBaseMessageViewHolderBinding parent, int viewType) {
        super(parent, viewType);
    }

    @Override
    protected void addViewToMessageContainer() {
        binding = ChatMessageHospitalizationViewHolderBinding.inflate(LayoutInflater.from(parent.getContext()), getMessageContainer(), true);

    }


    @Override
    public void bindData(ChatMessageBean message, ChatMessageBean lastMessage) {
        super.bindData(message, lastMessage);
        currentMessage = message;
        attachment = (HospitalizationCertificateAttachment) message.getMessageData().getMessage().getAttachment();
        if (attachment == null) {
            return;
        }
        //设置ViewHolder展示UI的内容
//        binding.patientName.setText(attachment.getPatientName());
        binding.tvTypeName.setText("住院证");
        binding.describe.setText("诊断："+attachment.getDiagnosisName());
        binding.tvInpatientWard.setText("病区："+attachment.getInpatientWardName());

    }



    @Override
    protected void onMessageBackgroundConfig(ChatMessageBean messageBean) {
        super.onMessageBackgroundConfig(messageBean);
        boolean isReceivedMsg = MessageHelper.isReceivedMessage(messageBean);
        View firstChild = baseViewBinding.messageContainer.getChildAt(0);
        if (isReceivedMsg) {
            firstChild.setBackgroundResource(R.drawable.bg_custom_message);
        } else {
            firstChild.setBackgroundResource(R.drawable.bg_custom_message_out);
        }
    }
}
